package day01;

import java.io.File;

public class Test04 {
    public static void main(String[] args) {
        File file = new File("demo");
        delete(file);
    }

    public static void delete(File file) {
        //如果是文件夹就直接删除
        if (file.exists()) {
            File[] files = file.listFiles();
            for (File file1 : files) {
                if (file1.isFile()) {
                    //如果是文件就删除
                    file1.delete();
                }else {
                    delete(file1);
                }
            }
            file.delete();
        }
    }
}